//
//  DFRouter.h
//  DFRouterDemo
//
//  Created by 如佳 陈 on 16/6/29.
//  Copyright © 2016年 rongzi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

extern NSString *const DFRouterParamSepartor;
extern NSString *const DFRouterEqual;
extern NSString *const DFRouterAnd;


@protocol DFRouterConfig <NSObject>

@required

/**
 @return 需要知道整个app的UITabBarController
 */
- (UITabBarController *)mainTabBarController;


/**
 @return 跳转协议名称 example: "app://page1/action1" 则返回app
 */
- (NSString *)schemeName;


/**
 @return 返回最顶部的UIViewController
 */
- (UIViewController *)topViewController;

@end

@protocol DFRouterPage <NSObject>

@optional

/**
 @return 获取页面实例方法，可使用init或者在storyboard中初始化
 */
+ (instancetype)getInstance;


/**
 处理参数，不实现则通过kvc赋值
 @param params 参数
 */
- (void)setParams:(NSDictionary *)params;

/**
 如果是个某个UINavigationController的根视图控制器，则需要告知所在tabbar的index
 */
-(NSInteger)tabbarIndex;

@end

@interface DFRouter : NSObject

/**
 必要，启动app时调用，写入配置
 
 @param config 配置
 */
+ (void)startWithConfig:(id<DFRouterConfig>)config;

/**
 注册一个url

 @param urlString url
 @param clazz     controller类
 */
+ (void)registerURL:(NSString *)urlString forViewController:(Class)clazz;

+ (UIViewController*)pageWithURL:(NSString*)urlString;

+ (UIViewController *)pageWithURL:(NSString *)urlString withParams:(NSDictionary *)params;

+ (UIViewController*)pageWithURL:(NSString*)urlString withNav:(BOOL)nav;

+ (UIViewController*)pageWithURL:(NSString*)urlString withNav:(BOOL)nav withParams:(NSDictionary*)params;

+ (id)openURL:(NSString *)urlString;

+ (id)openURL:(NSString *)urlString withParams:(NSDictionary *)params;

@end
